package geos;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JOptionPane;

public class DAOStatusOrcamento {

    int cod_status;
    String ds_status;

    public DAOStatusOrcamento(int cod_status, String ds_status) {
        this.cod_status = cod_status;
        this.ds_status = ds_status;
    }

    public int getCod_status() {
        return cod_status;
    }

    public void setCod_status(int cod_status) {
        this.cod_status = cod_status;
    }

    public String getDs_status() {
        return ds_status;
    }

    public void setDs_status(String ds_status) {
        this.ds_status = ds_status;
    }

    
    public boolean InsertStatusOrcamento() {
        try {
            String sql = "INSERT INTO `geos`.`statusorcamento`VALUES(null,?);";
            Connection connection;
            connection = Banco.getConnection();
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setInt(1, this.getCod_status());
            ps.setString(2, this.getDs_status());
                        
            boolean result = ps.execute();
            System.out.println(ps);
            return result;
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "Erro de SQL. Detalhes:" + e.getMessage());
            return false;
        } catch (NullPointerException e) {
            JOptionPane.showMessageDialog(null, "Conexão Nula");
            return false;
        }

    }

}
